package donjuan;

import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;

class Dialog_mode extends JDialog implements ActionListener {//显示对话框来确定是否需要精准查找
  public static boolean mode = false;
  
  JButton yes;
  
  JButton no;
  
  JLabel hint;
  
  JTextArea cin;
  
  Dialog_mode() {
    setLayout(new FlowLayout());
    setVisible(true);
    setTitle("是否精准查找");
    setLocation(650, 300);
    init();
    pack();
  }
  
  void init() {
    this.no = new JButton("关键词查找");
    this.yes = new JButton("是，精准查找");
    this.cin = new JTextArea(10, 20);
    this.yes.addActionListener(this);
    this.no.addActionListener(this);
    JSplitPane fir = new JSplitPane(1, this.yes, this.no);
    JSplitPane sec = new JSplitPane(0, fir, this.cin);
    yes.setBorder(BorderFactory.createRaisedBevelBorder());
    yes.setFont(new Font("华文新魏",1,15));
    no.setBorder(BorderFactory.createRaisedBevelBorder());
    no.setFont(new Font("华文新魏",1,15));
    
    add(sec);
  }
  
  public void actionPerformed(ActionEvent e) {//点击之后依据响应来创建新的窗口并隐藏当前窗口
    if (e.getSource() == this.yes) {
      String s = this.cin.getText();
      Message.show.setVisible(false);
      ArrayList<Integer> numb = Readin.search_data(Message.read, s, true);
      dispose();
      Window_decide window_decide = new Window_decide(numb, Window_manage.status, s);
    } else if (e.getSource() == this.no) {
      String s = this.cin.getText();
      Message.show.setVisible(false);
      ArrayList<Integer> numb = Readin.search_data(Message.read, s, false);
      dispose();
      Window_decide window_decide = new Window_decide(numb, Window_manage.status, s);
    } 
  }
}
